﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameEngine
{
    class Button
    {
        private Vector2 _Position;
        private Vector2 _SchriftPosition;
        private SpriteFont _Schriftart;
        private Texture2D _Texture;
        private Texture2D _TextureAktiv;
        private string _Text;

        public Vector2 Position
        {
            get { return _Position; }
            set { _Position = value; }
        }

        public Vector2 SchriftPosition
        {
            get { return _SchriftPosition; }
            set { _SchriftPosition = value; }
        }

        public SpriteFont Schriftart
        {
            get { return _Schriftart; }
            set { _Schriftart = value; }
        }

        public Texture2D Texture
        {
            get { return _Texture; }
            set { _Texture = value; }
        }

        public Texture2D TextureAktiv
        {
            get { return _TextureAktiv; }
            set { _TextureAktiv = value; }
        }

        public string Text
        {
            get { return _Text; }
            set { _Text = value; }
        }

        public void Draw(SpriteBatch sb)
        {
            MouseState ms = Mouse.GetState();

            if (ms.X > _Position.X && ms.X < (_Position.X + _Texture.Width) &&
                ms.Y > _Position.Y && ms.Y < (_Position.Y + _Texture.Height))
            {
                sb.Draw(this._TextureAktiv, this._Position, Color.White);
            }
            else
            {
                sb.Draw(this._Texture, this._Position, Color.White);
            }

            sb.DrawString(this._Schriftart, this._Text, this._SchriftPosition, Color.Black);
        }

        public bool IsActive()
        {
            MouseState ms = Mouse.GetState();

            if (ms.X > _Position.X && ms.X < (_Position.X + _Texture.Width) &&
            ms.Y > _Position.Y && ms.Y < (_Position.Y + _Texture.Height))
            {
                return true;
            }
            return false;
        }
    }
}
